import Layouts from '@/layouts/index.vue'
import Dashboard from '@/views/Dashboard.vue'
import ErrorPage from '@/views/error.vue'
import { createRouter, createWebHistory } from 'vue-router'

const staticRoutes = [
  {
    path: '/login',
    name: 'login',
    meta: { title: '登录' },
    component: () => import('@/views/login/index2.vue'),
  },
  {
    path: '/error',
    name: 'error',
    component: ErrorPage,
  },
  {
    path: '/',
    name: 'index',
    meta: { title: '首页' },
    redirect: '/home',
    component: Layouts,
    children: [
      {
        path: '/home',
        name: 'Dashboard',
        meta: { title: '仪表盘' },
        component: Dashboard,
      },
    ],
  },
  // {
  //   path: '/system',
  //   name: 'system',
  //   meta: { title: '系统管理' },
  //   component: Layouts,
  //   children: [
  //     {
  //       path: '/system/menu',
  //       name: 'SystemMenu',
  //       meta: { title: '菜单管理' },
  //       component: () => import('@/views/system/menu/index.vue'),
  //     },
  //     {
  //       path: '/system/account',
  //       name: 'SystemAccount',
  //       meta: { title: '账号管理' },
  //       component: () => import('@/views/system/account/index.vue'),
  //     },
  //   ],
  // },
  // {
  //   path: '/dispatch',
  //   name: 'dispatch',
  //   meta: { title: '收发存' },
  //   component: Layouts,
  //   children: [
  //     {
  //       path: '/dispatch/instorage',
  //       name: 'dispatchInstorage',
  //       meta: { title: '入库明细' },
  //       component: () => import('@/views/dispatch/instorage/index.vue'),
  //     },
  //     {
  //       path: '/dispatch/outstorage',
  //       name: 'dispatchOutstorage',
  //       meta: { title: '出库明细' },
  //       component: () => import('@/views/dispatch/outstorage/index.vue'),
  //     },

  //   ],
  // },
]

// 动态路由
export const dynamicRoutes: any[] = []

const router = createRouter({
  history: createWebHistory(),
  routes: staticRoutes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    }
    else {
      return { top: 0 }
    }
  },
})

export default router
